import { http } from "@/utils/http";
import type { GetCourseListResponse, GetCourseDetailResponse } from "./types";

/**
 * 获取课程列表
 * @returns GetCourseListResponse
 */
export const getCourseListApi = (page: number, limit: number) => {
  return http.get<GetCourseListResponse>(`/api/edu/course/${page}/${limit}`);
};

/**
 * 获取课程详情
 * @param id 课程id
 * @returns GetCourseDetailResponse
 */
export const getCourseDetailApi = (id: string) => {
  return http.get<GetCourseDetailResponse>(`/api/edu/course/${id}`);
};

/**
 * 收藏课程
 * @param id 课程id
 * @returns
 */
export const collectCourseApi = (id: string) => {
  return http.post<{}>(`/api/edu/courseCollect/auth/save/${id}`);
};

/**
 * 取消收藏课程
 * @param id 课程id
 * @returns
 */
export const cancelCollectCourseApi = (id: string) => {
  return http.delete<{}>(`/api/edu/courseCollect/auth/remove/${id}`);
};

/**
 * 获取视频播放地址
 * @param videoSourceId 视频id
 * @returns playURL
 */
export const getVideoUrlApi = (videoSourceId: string) => {
  return http.get<{
    playURL: string;
  }>(`/api/vod/video/getPlayURL/${videoSourceId}`);
};
